import { Injectable } from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'
import { JwtPayload } from './interfaces/jwt-payload.interface'
// import { UserService } from '../user/user.service'

@Injectable()
export class AuthService {
  constructor(private readonly jwtService: JwtService) {}

  async createToken() {
    const user: JwtPayload = { email: 'a@awoo.co' }
    console.log(user)
    const accessToken = this.jwtService.sign(user)
    return {
      expiresIn: 3600,
      accessToken,
    }
  }

  async validateUser(payload: JwtPayload): Promise<any> {
    // put some validation logic here
    // for example query user by id/email/username
    return {}
  }
}
